package Vista;


import Modelo.Grafico;
import java.awt.Dimension;
import java.sql.SQLException;
import java.text.DecimalFormat;
import javax.swing.JLabel;

public final class PorcentajeDeVentas extends javax.swing.JFrame {
    

    //Constructor
     public PorcentajeDeVentas() throws SQLException {
        initComponents();        
        this.setLocationRelativeTo(null); 
    }


    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jPanel7 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jDateInicial = new com.toedter.calendar.JDateChooser();
        jDateFinal = new com.toedter.calendar.JDateChooser();
        jPanel6 = new javax.swing.JPanel();
        jRadioGraficaArea = new javax.swing.JRadioButton();
        jRadioBarra2D = new javax.swing.JRadioButton();
        jRadioBarra3D = new javax.swing.JRadioButton();
        jRadioPastel2D = new javax.swing.JRadioButton();
        jRadioPastel3D = new javax.swing.JRadioButton();
        jPanel1 = new javax.swing.JPanel();
        CONTENEDOR = new javax.swing.JPanel();
        GUARDAR1 = new javax.swing.JButton();
        GUARDAR = new javax.swing.JButton();
        jButtonConsulta = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jTextZona = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jRadioProducto = new javax.swing.JRadioButton();
        jRadioZona = new javax.swing.JRadioButton();
        jLabelDescripcion = new javax.swing.JLabel();

        jPanel7.setBackground(new java.awt.Color(255, 255, 255));
        jPanel7.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        jPanel5.setBackground(new java.awt.Color(255, 255, 255));
        jPanel5.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel5.setBackground(new java.awt.Color(255, 255, 255));
        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel5.setForeground(new java.awt.Color(51, 0, 0));
        jLabel5.setText("Fecha Inicial (dd/mm/aaaa):");

        jLabel6.setBackground(new java.awt.Color(255, 255, 255));
        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel6.setForeground(new java.awt.Color(51, 0, 0));
        jLabel6.setText("Fecha Final (dd/mm/aaaa):");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jDateInicial, javax.swing.GroupLayout.DEFAULT_SIZE, 133, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                        .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jDateFinal, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jDateInicial, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jDateFinal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6))
                .addContainerGap(16, Short.MAX_VALUE))
        );

        jPanel6.setBackground(new java.awt.Color(255, 255, 255));
        jPanel6.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jRadioGraficaArea.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup2.add(jRadioGraficaArea);
        jRadioGraficaArea.setText("Area");

        jRadioBarra2D.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup2.add(jRadioBarra2D);
        jRadioBarra2D.setText("Barra 2D");

        jRadioBarra3D.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup2.add(jRadioBarra3D);
        jRadioBarra3D.setSelected(true);
        jRadioBarra3D.setText("Barra 3D");

        jRadioPastel2D.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup2.add(jRadioPastel2D);
        jRadioPastel2D.setText("Pastel 2D");

        jRadioPastel3D.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup2.add(jRadioPastel3D);
        jRadioPastel3D.setText("Pastel 3D");

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jRadioGraficaArea)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 40, Short.MAX_VALUE)
                        .addComponent(jRadioBarra2D)
                        .addGap(18, 18, 18)
                        .addComponent(jRadioBarra3D))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jRadioPastel2D)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jRadioPastel3D)))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioGraficaArea)
                    .addComponent(jRadioBarra3D)
                    .addComponent(jRadioBarra2D))
                .addGap(18, 18, 18)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jRadioPastel2D)
                    .addComponent(jRadioPastel3D))
                .addContainerGap(17, Short.MAX_VALUE))
        );

        jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        CONTENEDOR.setBackground(new java.awt.Color(250, 250, 250));
        CONTENEDOR.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        javax.swing.GroupLayout CONTENEDORLayout = new javax.swing.GroupLayout(CONTENEDOR);
        CONTENEDOR.setLayout(CONTENEDORLayout);
        CONTENEDORLayout.setHorizontalGroup(
            CONTENEDORLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 910, Short.MAX_VALUE)
        );
        CONTENEDORLayout.setVerticalGroup(
            CONTENEDORLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 480, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(CONTENEDOR, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(CONTENEDOR, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        GUARDAR1.setForeground(new java.awt.Color(51, 0, 0));
        GUARDAR1.setText("Terminar");

        GUARDAR.setForeground(new java.awt.Color(51, 0, 0));
        GUARDAR.setText("Guardar Informe");
        GUARDAR.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GUARDARActionPerformed(evt);
            }
        });

        jButtonConsulta.setForeground(new java.awt.Color(51, 0, 0));
        jButtonConsulta.setText("Mostrar Informe");
        jButtonConsulta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonConsultaActionPerformed(evt);
            }
        });

        jLabel1.setBackground(new java.awt.Color(255, 255, 255));
        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 20));
        jLabel1.setForeground(new java.awt.Color(102, 0, 0));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/rutascoronasa/resources/Imagenes/registro de porcentaje de ventas.png"))); // NOI18N

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel4.setBackground(new java.awt.Color(255, 255, 255));
        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14));
        jLabel4.setForeground(new java.awt.Color(51, 0, 0));
        jLabel4.setText("Generar Informe:");

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
        jPanel4.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jRadioProducto.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(jRadioProducto);
        jRadioProducto.setText("Codigo de Producto");

        jRadioZona.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(jRadioZona);
        jRadioZona.setSelected(true);
        jRadioZona.setText("Zona de Ventas ");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jRadioZona)
                    .addComponent(jRadioProducto))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jRadioZona)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jRadioProducto)
                .addGap(11, 11, 11))
        );

        jLabelDescripcion.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabelDescripcion.setForeground(new java.awt.Color(51, 102, 0));
        jLabelDescripcion.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jTextZona, javax.swing.GroupLayout.DEFAULT_SIZE, 55, Short.MAX_VALUE))
                    .addComponent(jLabelDescripcion, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(jTextZona, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(7, 7, 7)
                        .addComponent(jLabelDescripcion, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
                        .addComponent(jButtonConsulta, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(GUARDAR, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(GUARDAR1, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel7Layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1))
                .addContainerGap())
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(6, 6, 6)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(GUARDAR1)
                    .addComponent(GUARDAR)
                    .addComponent(jButtonConsulta))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButtonConsultaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonConsultaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButtonConsultaActionPerformed

    private void GUARDARActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GUARDARActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_GUARDARActionPerformed

    /**
    * @param args the command line arguments
    */
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel CONTENEDOR;
    private javax.swing.JButton GUARDAR;
    private javax.swing.JButton GUARDAR1;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JButton jButtonConsulta;
    private com.toedter.calendar.JDateChooser jDateFinal;
    private com.toedter.calendar.JDateChooser jDateInicial;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabelDescripcion;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JRadioButton jRadioBarra2D;
    private javax.swing.JRadioButton jRadioBarra3D;
    private javax.swing.JRadioButton jRadioGraficaArea;
    private javax.swing.JRadioButton jRadioPastel2D;
    private javax.swing.JRadioButton jRadioPastel3D;
    private javax.swing.JRadioButton jRadioProducto;
    private javax.swing.JRadioButton jRadioZona;
    private javax.swing.JTextField jTextZona;
    // End of variables declaration//GEN-END:variables

 public int tipoGrafica(){
        if(jRadioGraficaArea.isSelected())
            return 1;
        else if(jRadioBarra2D.isSelected())
            return 2;
        else if(jRadioBarra3D.isSelected())
            return 3;
     /*   else if(jRadioBarraLinea.isSelected())
            return 4;
        else if(jRadioLinea3D.isSelected())
            return 5;*/
        else if(jRadioPastel2D.isSelected())
            return 6;
        else
            return 7;
    }

 /**
  * reviza cual radio esta activo, para ejecutar la accion correspondiente
  */
 public void generarGrafica(){
     if(jRadioZona.isSelected()){
       //graficaZona();
     }else{
       //graficaProdu();
     }
 }

 /**
  * consolida los productos dependiendo del vendedor
  */
   public void graficaZona(){      
    Grafico migrafico = new Grafico();
    /*  Vendedor refVendedor;
      String zona=jTextZona.getText()+"";
      refVendedor=refVendedores.getReferenciaVendedorZona(zona);

      if(refVendedor!=null)
          jLabelDescripcion.setText(refVendedor.getNombre());
     /**/

      java.sql.Date inicial;
      java.sql.Date ffinal;
      //tamaño del grafico
      CONTENEDOR.removeAll();
      CONTENEDOR.setVisible(false);
      CONTENEDOR.setVisible(true);//Actualizo el contenedor
      Dimension d = CONTENEDOR.getSize();//toma el tamaño del contenedor

        inicial = new java.sql.Date(jDateInicial.getDate().getTime());
        ffinal = new java.sql.Date(jDateFinal.getDate().getTime());

     /*   Factura[] vectorFacturas=refFacturas.getListadoFacturasZonaFecha(jTextZona.getText(),fechaInicial,fechaFinal);
       
     
        double[] cantidades=new double[cantidad];
        String[] descripcion=new String[cantidad];
        String[] vacio=new String[cantidad];
        double total=0;
        for(int x=0;x<cantidad;x++){
            if(matriz.infor().getCantidad()!=0){
                descripcion[x]=matriz.infor().getRefProducto().getDescripcion();
                cantidades[x]=matriz.infor().getCantidad();
                vacio[x]="";
                total+=cantidades[x];
                matriz.siguiente();
            }
        }
        
        for(int x=0;x<cantidad;x++)
            if(cantidades[x]!=0.0)                
                cantidades[x]=(cantidades[x]*100)/total;  

        matriz=null;     
        //Unimos descripciones con cantidades %
        DecimalFormat decf = new DecimalFormat("###.##");
        for(int x=0;x<cantidad;x++)
            if(cantidades[x]!=0.0)
                descripcion[x]=descripcion[x]+" "+ decf.format(cantidades[x]) +"%";            
        
 
        //**********************************grafica**********************************************************        
        //se crean los datos
        //arg1 valores en el cuadrito dandole nombre
        //arg2 son los valores en las x
        double[] valores =cantidades;//{1,2,3};//cantidades;
        String[] arg1 = descripcion;//{"a","b","c"};//descripcion;
        String[] arg2 = vacio;//{"","",""};///vacio;
        //titulo, lateral 1, lateral 2
        String[] data = {"Porcentaje de Venta de Productos Vendedor: "+jLabelDescripcion.getText()+" \nInforme a la Fecha: " + jTextFechaInicial.getText() + " al " + jTextFechaFinal.getText(),"Productos","Porcentaje de Ventas"};
        //se crea el grafico
        //arg1 valores en el cuadrito dandole nombre
        //arg2 son los valores en las x
        

        migrafico.crear_grafico_de_barras(d, valores, arg1, arg2, data,tipoGrafica());
        //se crea un jlabel para colocar el grafico
        JLabel j = new JLabel();
        j.setBounds(0, 0, d.width, d.height);
        //se carga el grafico de memoria
        migrafico.cargar_grafico(j);
        //se añade al contenedor
        //CONTENEDOR.update(null);
        CONTENEDOR.add(j);
        
        this.repaint();

        // JOptionPane.showMessageDialog(null,"Informe Ha Sido Generado Correctamente");
      }else
        JOptionPane.showMessageDialog(null,"Zona No Registra Ventas");    
       
    }

/**
 public void graficaProdu(){
     Grafico migrafico = new Grafico();
      Producto refProducto;
      String codigo=jTextZona.getText()+"";
      refProducto=refProductos.getReferenciaProducto(codigo);
      if(refProducto!=null)
          jLabelDescripcion.setText(refProducto.getDescripcion());
      else{
            jLabelDescripcion.setText("");
            JOptionPane.showMessageDialog(null,"Producto no registrado");
      }



         //tamaño del grafico
      CONTENEDOR.removeAll();
      CONTENEDOR.setVisible(false);
      CONTENEDOR.setVisible(true);//Actualizo el contenedor

        Dimension d = CONTENEDOR.getSize();//toma el tamaño del contenedor

        Calendar fechaInicial = new GregorianCalendar();
        Calendar fechaFinal = new GregorianCalendar();

        int diaInicial=diaMesAño(jTextFechaInicial.getText(),1);
        int mesInicial=diaMesAño(jTextFechaInicial.getText(),2);
        int añoInicial=diaMesAño(jTextFechaInicial.getText(),3);
        int diaFinal=diaMesAño(jTextFechaFinal.getText(),1);
        int mesFinal=diaMesAño(jTextFechaFinal.getText(),2);
        int añoFinal=diaMesAño(jTextFechaFinal.getText(),3);

        fechaInicial.set(añoInicial, mesInicial, diaInicial);
        fechaFinal.set(añoFinal,mesFinal,diaFinal);

        Factura[] vectorFacturas=refFacturas.getListadoFacturasZonaFecha("20",fechaInicial,fechaFinal);//20 me trae todas las facturas
       //en vector factura tengo todas las facturas de esa fecha
        // toca dividir por zonas
    if(vectorFacturas[0]!=null){
        ListaNodo<Detalles> matriz=refFacturas.getConsolidadoZona(vectorFacturas,jTextZona.getText());

       //{"Codigo", "Descripcion", "Cantidad"};
       // JOptionPane.showMessageDialog(null, matrizCantidades.length);
        matriz.reiniciar();
        int cantidad=0;
        while(!matriz.fin()){
            if(matriz.infor().getCantidad()!=0)
                cantidad++;
            matriz.siguiente();
        }

        double[] cantidades=new double[cantidad];
        String[] descripcion=new String[cantidad];
        String[] vacio=new String[cantidad];
        double total=0;
        matriz.reiniciar();
        for(int x=0;x<cantidad;x++){
            if(matriz.infor().getCantidad()!=0){
                descripcion[x]=matriz.getClave() + " " + refVendedores.getReferenciaVendedorZona(matriz.getClave()).getNombre();
                cantidades[x]=matriz.infor().getCantidad();
                vacio[x]="";
                total+=cantidades[x];
                matriz.siguiente();
            }
        }

        for(int x=0;x<cantidad;x++)
            if(cantidades[x]!=0.0)
                cantidades[x]=(cantidades[x]*100)/total;

        //Unimos descripciones con cantidades %
        DecimalFormat decf = new DecimalFormat("###.##");
        for(int x=0;x<cantidad;x++){
            if(cantidades[x]!=0.0){
                descripcion[x]=descripcion[x]+" "+ decf.format(cantidades[x]) +"%";
            }
        }
        //se crean los datos
       //arg1 valores en el cuadrito dandole nombre
         //arg2 son los valores en las x
        double[] valores =cantidades;//{1,2,3};//cantidades;
        String[] arg1 = descripcion;//{"a","b","c"};//vacio;
        String[] arg2 = vacio;//{"","",""};///descripcion;
        //titulo, lateral 1, lateral 2
        String[] data = {"Porcentaje de Venta de "+ jLabelDescripcion.getText() +" Por Zonas\nInforme a la Fecha: " + jTextFechaInicial.getText() + " al " + jTextFechaFinal.getText(),"Productos","Porcentaje de Ventas"};
        //se crea el grafico
          //arg1 valores en el cuadrito dandole nombre
         //arg2 son los valores en las x
        //****************************crea el grafico*************************************************
        migrafico.crear_grafico_de_barras(d, valores, arg1, arg2, data,tipoGrafica());
        //se crea un jlabel para colocar el grafico
        JLabel j = new JLabel();
        j.setBounds(0, 0, d.width, d.height);
        //se carga el grafico de memoria
        migrafico.cargar_grafico(j);
        //se añade al contenedor
        //CONTENEDOR.update(null);
        CONTENEDOR.add(j);

        this.repaint();

        // JOptionPane.showMessageDialog(null,"Informe Ha Sido Generado Correctamente");
      }else
        JOptionPane.showMessageDialog(null,"Codigo de Producto No Registra Ventas");

    }*/
    }
}
